<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>📚 个人读书追踪器</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <div class="container">
        <header class="header">
            <h1>📚 个人读书追踪器</h1>
            <p>记录、管理和追踪您的阅读进度</p>
        </header>

        <main class="main">
            <!-- 操作栏 -->
            <section class="action-bar">
                <div class="search-filter">
                    <div class="search-group">
                        <input type="text" id="search-input" placeholder="搜索书名或作者...">
                        <button id="search-btn" class="search-btn">🔍</button>
                    </div>
                    <div class="filter-group">
                        <select id="status-filter" class="filter-select">
                            <option value="all">全部状态</option>
                            <option value="想读">想读</option>
                            <option value="在读">在读</option>
                            <option value="已读">已读</option>
                        </select>
                        <select id="sort-select" class="filter-select">
                            <option value="title-asc">书名 A-Z</option>
                            <option value="title-desc">书名 Z-A</option>
                            <option value="author-asc">作者 A-Z</option>
                            <option value="author-desc">作者 Z-A</option>
                            <option value="rating-desc">评分 高-低</option>
                            <option value="rating-asc">评分 低-高</option>
                        </select>
                    </div>
                </div>
                <button id="add-book-btn" class="primary-btn">
                    ➕ 添加新书籍
                </button>
            </section>

            <!-- 统计信息卡片 -->
            <section class="stats-cards">
                <div class="stat-card">
                    <div class="stat-value" id="total-books">0</div>
                    <div class="stat-label">总书籍数</div>
                </div>
                <div class="stat-card">
                    <div class="stat-value" id="read-books">0</div>
                    <div class="stat-label">已读书籍</div>
                </div>
                <div class="stat-card">
                    <div class="stat-value" id="reading-books">0</div>
                    <div class="stat-label">在读书籍</div>
                </div>
                <div class="stat-card">
                    <div class="stat-value" id="want-read-books">0</div>
                    <div class="stat-label">想读书籍</div>
                </div>
                <div class="stat-card">
                    <div class="stat-value" id="avg-rating">0.0</div>
                    <div class="stat-label">平均评分</div>
                </div>
            </section>

            <!-- 书籍列表 -->
            <section class="books-section">
                <h2>我的书架</h2>
                <div id="books-container" class="books-container">
                    <!-- 空状态提示 -->
                    <div id="empty-state" class="empty-state">
                        <div class="empty-icon">📖</div>
                        <p>您的书架还是空的</p>
                        <p>点击「添加新书籍」开始记录您的阅读</p>
                    </div>
                    
                    <!-- 书籍卡片将通过JavaScript动态生成 -->
                </div>
            </section>
        </main>

        <footer class="footer">
            <p>💡 提示: 所有数据保存在本地浏览器中，请定期备份您的数据</p>
        </footer>
    </div>

    <!-- 添加/编辑书籍模态框 -->
    <div id="book-modal" class="modal">
        <div class="modal-content">
            <div class="modal-header">
                <h3 id="modal-title">添加新书籍</h3>
                <button id="close-modal" class="close-btn">×</button>
            </div>
            
            <form id="book-form" class="book-form">
                <input type="hidden" id="book-id">
                
                <div class="form-group">
                    <label for="book-title">书名 *</label>
                    <input type="text" id="book-title" required placeholder="请输入书名">
                </div>
                
                <div class="form-group">
                    <label for="book-author">作者 *</label>
                    <input type="text" id="book-author" required placeholder="请输入作者">
                </div>
                
                <div class="form-row">
                    <div class="form-group">
                        <label for="book-pages">页数</label>
                        <input type="number" id="book-pages" min="0" placeholder="请输入页数">
                    </div>
                    
                    <div class="form-group">
                        <label for="book-status">阅读状态 *</label>
                        <select id="book-status" required>
                            <option value="想读">想读</option>
                            <option value="在读">在读</option>
                            <option value="已读">已读</option>
                        </select>
                    </div>
                    
                    <div class="form-group">
                        <label for="book-rating">评分</label>
                        <select id="book-rating">
                            <option value="">未评分</option>
                            <option value="1">⭐</option>
                            <option value="2">⭐⭐</option>
                            <option value="3">⭐⭐⭐</option>
                            <option value="4">⭐⭐⭐⭐</option>
                            <option value="5">⭐⭐⭐⭐⭐</option>
                        </select>
                    </div>
                </div>
                
                <div class="form-group">
                    <label for="book-review">评论/笔记</label>
                    <textarea id="book-review" rows="4" placeholder="记录您的读后感或笔记..."></textarea>
                </div>
                
                <div class="form-actions">
                    <button type="button" id="cancel-btn" class="cancel-btn">取消</button>
                    <button type="submit" class="primary-btn">保存书籍</button>
                </div>
            </form>
        </div>
    </div>

    <!-- 确认删除模态框 -->
    <div id="delete-modal" class="modal">
        <div class="modal-content small-modal">
            <div class="modal-header">
                <h3>确认删除</h3>
                <button id="close-delete-modal" class="close-btn">×</button>
            </div>
            
            <div class="modal-body">
                <p>确定要删除这本书籍吗？此操作无法撤销。</p>
                <p class="book-to-delete"></p>
            </div>
            
            <div class="form-actions">
                <button id="cancel-delete-btn" class="cancel-btn">取消</button>
                <button id="confirm-delete-btn" class="delete-btn">删除</button>
            </div>
        </div>
    </div>

    <!-- 消息提示 -->
    <div id="toast" class="toast"></div>

    <script src="script.js"></script>
</body>
</html>